<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg"%>
<%
	String path=request.getContextPath();
	String basePath=request.getScheme()+"://"
			+request.getServerName()+":"+request.getServerPort()
			+path+"/";
%>
<!DOCTYPE html>
<html>
<base href="<%=basePath%>">
<head>
	<title>写论坛</title>
	<meta charset="utf-8">
	<link rel="icon" href="img/logo.png" sizes="32x32">
	<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
	<link rel="stylesheet" type="text/css" href="css/problem.css">
	<link rel="stylesheet" href="styles/default.css">
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript" src="js/popper.min.js"></script>
	<script type="text/javascript" src="js/bootstrap.js"></script>
    <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
    <script src="layui/layui.js"></script>
	<style type="text/css">
		.img-circle{
			border-radius: 50%;
		}
		.dropdown-menu .link-myspace:hover{
			color:black;
		}
	</style>
</head>
<body style="background:url('img/ba.png');background-size: auto;background-color: rgba(0,0,0,0.1);">
	<!-- 顶部导航 -->
	<div class="nav fixed-top">
		<div class="container">
			<div class="top-title"><span>OnlineJudge</span></div>
			<div class="top-list">
				<ul>
					<li class=""><a href="problem/list?pager.offset=0">题库</a></li>
					<li class=""><a href="solution/list?pager.offset=0">题解</a></li>
					<li class="active1"><a href="community/list?pager.offset=0">论坛</a></li>
				</ul>
			</div>
			<div class="top-last">
				<c:if test="${currentUser!=null }">
					<a href="user/myspace" class="dropdown-toggle" data-toggle="dropdown">
	                    <img class="img-circle" src="${pageContext.request.contextPath }/img/${currentUser.getUserImg() }" style="margin: -5px;" width="35px">
	                    &nbsp;
	                    <strong id="id_user_username">${currentUser.getUserName() }</strong>
	                    <b class="caret"></b>
                	</a>
                	<ul class="dropdown-menu" style="width:50px;margin-top:16px;font-size: 13px;text-align: center">
                		<li style="padding: 0;"><hr style="margin:0;"><a class="link-myspace" href="user/myspace" style="font-size:14px;">个人中心</a></li>
                		<li style="padding: 0;"><hr style="margin:0;"><a class="btn btn-outline-primary btn-lg btn-block" role="button" href="user/logout" style="font-size:14px;">退出登录</a></li>
                    </ul>
				</c:if>
				<!-- 
				<c:if test="${currentUser==null }">
					<a href="javascript:void(0);" onclick="syalert.syopen('alert1')">登录/注册</a>
				</c:if>
				 -->
			</div>
		</div>
	</div>

	<!-- 内容 -->
	<div class="container" style="margin-top: 70px;">
		<div class="panel panel-default">
			<div class="panel-body">
				<h3 align="center" style="margin-top: 20px;margin-bottom: 20px;">写文章</h3>
				<hr>
				<form action="community/writeCommunity" method="post" id="form">
					<div class="form-group">
						<label for="title" style="font-weight: bold;"><i style="color: red;font-size: 14px;">*&nbsp;</i>文章标题</label>
						<input type="text" class="form-control" name="itemTitle" id="itemTitle" aria-describedby="textHelp">
						<small id="emailHelp" class="form-text text-muted">*&nbsp;字数不要超过20字</small>
					</div>
					<input type="hidden" name="userId" value="${currentUser.getUserId() }">
					<input type="hidden" name="itemContent" id="itemContent">
					<textarea name="editor1" id="editor1"></textarea>
	            	<script>
	                	var editor=CKEDITOR.replace('editor1');
	            	</script>
	            	<button type="submit" id="submitComment" class="form-control btn btn-outline-primary" style="font-size: 14px;margin-top: 20px;">发布文章</button>
				</form>
			</div>
		</div>
	</div>
	<script type="text/javascript">
		// editor.getData();
		layui.use('layer', function() {
			var layer = layui.layer;
			var $ = layui.jquery;
			//表单验证
			$("#form").submit(function() {
				$("#itemContent").val(editor.getData());
				if($("#itemTitle").val()==""){
					layer.msg('文章标题不能为空', { icon: 2, time: 1000, shade: [0.6, '#000', true] });
					return false;
				}else if(editor.getData()==""){
					layer.msg('文章内容不能为空', { icon: 2, time: 1000, shade: [0.6, '#000', true] });
					return false;
				}
				return true;
			});
		});
	</script>
</body>
</html>